package parsing;

import java.io.File;
import java.io.FileNotFoundException;
import java.util.Scanner;

public class ParsingTools {

	
	//Parses a file (script) to a valid string
    public   static String File2String(String filePath) {

        // Location of file to read
         File file = new File(filePath);
         String theString = null;

         try {

             Scanner scanner = new Scanner(file);
             theString = "";//the final string

             while (scanner.hasNextLine()) {
                 String line = scanner.nextLine();
                 if (line.charAt(line.length() - 1) == ';') {
                	 theString = theString + ' ' + line + '\n';
                 } else {
                	 theString = theString + ' ' + line;
                 }
             }
             scanner.close();
             //System.out.println(theString);

         } catch (FileNotFoundException e) {
             e.printStackTrace();
         }
         
         
		return theString;

     }

    public static int GetCountryIDFromCode (String str) {
    	str=str.toUpperCase();
        int a = str.charAt(0);
        int b = str.charAt(1);
       

        a <<= 8;
        b |= a;

        return b;
    }

    
  
}
